//
//  JCUserModel.swift
//  JCNewsForMac
//
//  Created by ifly on 13/7/18.
//  Copyright © 2018年 Ismail. All rights reserved.
//

import Cocoa
import HandyJSON

class JCUserModel: HandyJSON {
    
    var Admin_PassWord = String()
    var Admin_UserName = String()
    var Admin_id = String()
    var Token = String()
    var id = String()
    
    class func saveUser(fordDic userDic:NSDictionary){
        UserDefaults.standard.set(NSKeyedArchiver.archivedData(withRootObject: userDic), forKey: "USER")
    }
    
    class func isLog()->Bool{
        
        let userData:NSData? = UserDefaults.standard.object(forKey: "USER") as? NSData
        if (userData != nil) {
            return true
        }
        return false
    }
    class func share() -> JCUserModel{
        
        let userData:NSData? = UserDefaults.standard.object(forKey: "USER") as? NSData
        let userDic = NSKeyedUnarchiver.unarchiveObject(with: userData! as Data)
        let user:JCUserModel = JCUserModel.deserialize(from: userDic as? NSDictionary)!
        
        return user
    }
    required init() {}
}
